<?php

namespace app\api\controller;

use app\common\controller\Api;
use app\api\service\StudentService;

class Student extends Api
{
    protected $noNeedLogin = [];
    protected $noNeedRight = ['*'];

    /**
     * 新增
     *
     */
    public function add()
    {
        $data = $this->request->post();
        $res = StudentService::add($data);
        return json($res);
    }

    /**
     * 详情
     *
     */
    public function details()
    {
        $data['id'] = $this->request->post("id");
        $res = StudentService::details($data);
        return json($res);
    }

    /**
     * 编辑
     *
     */
    public function edit()
    {
        $data = $this->request->post();
        $res = StudentService::edit($data);
        return json($res);
    }

    /**
     * 默认
     *
     */
    public function default()
    {
        $data = $this->request->post();
        $res = StudentService::default($data);
        return json($res);
    }

    /**
     * 列表
     *
     */
    public function list(){
        $data['page'] = $this->request->get("page");
        $data['limit'] = $this->request->get("limit");
        $data['user_id'] = $this->auth->id;
        $res = StudentService::list($data);
        return json($res);
    }

    /**
     * 删除
     *
     */
    public function del()
    {
        $data['id'] = $this->request->post("id");
        $data['user_id'] = $this->auth->id;

        $res = StudentService::del($data);
        return json($res);
    }
}